//
//  MyJiFenViewController.m
//  JiuJiuShangCheng
//
//  Created by jiujiukeji on 2018/7/17.
//  Copyright © 2018年 jiujiukeji. All rights reserved.
//

#import "ChongZhiDetailViewController.h"
#import "MyJiFenTableViewCell.h"

@interface ChongZhiDetailViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArray;
@end

@implementation ChongZhiDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = UIColorWhite;
    [self loadBaseTitleLable:@"充值明细"];
    [self.view addSubview:self.tableView];
    [self getChongZhiList];
}
#pragma mark - 获取数据
- (void)getChongZhiList
{
    NSString *code = [NSString stringWithFormat:@"%@%@",safeCode,[GetTimestamp getNowTimeTimestamp]];
    [MBProgressHUD showMessage:nil toView:self.view];
    [TFNetworking getWithURLString:[NSString stringWithFormat:@"%@/api/json/member/member.ashx?action=recharge&companyid=%@&code=%@&timestamp=%@&pagesize=100000&pageindex=1",kServerURL,companyId,[MD5Encrypt  MD5ForLower32Bate:code],[GetTimestamp getNowTimeTimestamp]] parameters:nil success:^(id responseObject) {
        [MBProgressHUD hideHUDForView:self.view];
        self.dataArray = [NSMutableArray array];
        if ([responseObject[@"status"] intValue] == 1) {
            NSArray *array = responseObject[@"memberRechargeList"];
            for (NSDictionary *dic in array) {
                [self.dataArray addObject:dic];
            }
        }
        [self.tableView reloadData];
        
    } failure:^(NSError *error) {
        [TFHUD addRemindHUD:self.view message:@"网络不给力..."];
    }];
}
#pragma mark - tableView delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MyJiFenTableViewCell *cell = [[MyJiFenTableViewCell alloc] init];
    // 赋值
    if (self.dataArray.count != 0) {
        NSDictionary *dic = _dataArray[indexPath.row];
        cell.textLB.text = dic[@"rechareCaption"];
        cell.timeLB.text = [NSString stringWithFormat:@"操作时间：%@",dic[@"rechargeDate"]];
        cell.numLB.text = [NSString stringWithFormat:@"%@%@",dic[@"rechareJJ"],dic[@"rechargePrice"]];
    }
    cell.selectionStyle = NO;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return rateHeight(120);
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}
- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, SafeAreaTopHeight, kScreenWidth, kScreenHeight-SafeAreaTopHeight) style:(UITableViewStyleGrouped)];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = NO;
        _tableView.estimatedRowHeight = 0;
        _tableView.estimatedSectionFooterHeight = 0;
        _tableView.estimatedSectionHeaderHeight = 0;
    }
    return _tableView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
